/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * NeuroviewPreferences.java
 *
 * Created on Nov 1, 2010, 9:14:13 PM
 */

package app.neuroview;

import javax.swing.JFileChooser;

/**
 *
 * @author Risto Laakso <risto.laakso@gmail.com>
 */
public class NeuroviewPreferences extends javax.swing.JFrame {

    /** Creates new form NeuroviewPreferences */
    public NeuroviewPreferences() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
   // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
   private void initComponents() {

      jLabel1 = new javax.swing.JLabel();
      netmorphExec = new javax.swing.JTextField();
      browse = new javax.swing.JButton();
      ok = new javax.swing.JButton();
      cancel = new javax.swing.JButton();

      setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

      jLabel1.setText("Netmorph location:");

      netmorphExec.setText("c:\\netmorph\\netmorph.exe");

      browse.setText("Browse..");
      browse.addActionListener(new java.awt.event.ActionListener() {
         public void actionPerformed(java.awt.event.ActionEvent evt) {
            browseActionPerformed(evt);
         }
      });

      ok.setText("OK");
      ok.addActionListener(new java.awt.event.ActionListener() {
         public void actionPerformed(java.awt.event.ActionEvent evt) {
            okActionPerformed(evt);
         }
      });

      cancel.setText("Cancel");
      cancel.addActionListener(new java.awt.event.ActionListener() {
         public void actionPerformed(java.awt.event.ActionEvent evt) {
            cancelActionPerformed(evt);
         }
      });

      javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
      getContentPane().setLayout(layout);
      layout.setHorizontalGroup(
         layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
         .addGroup(layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(jLabel1)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(netmorphExec, javax.swing.GroupLayout.PREFERRED_SIZE, 247, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(browse)
            .addContainerGap(46, Short.MAX_VALUE))
         .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
            .addContainerGap(421, Short.MAX_VALUE)
            .addComponent(cancel)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(ok)
            .addContainerGap())
      );
      layout.setVerticalGroup(
         layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
         .addGroup(layout.createSequentialGroup()
            .addContainerGap()
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
               .addComponent(jLabel1)
               .addComponent(netmorphExec, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addComponent(browse))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 216, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
               .addComponent(ok)
               .addComponent(cancel))
            .addContainerGap())
      );

      pack();
   }// </editor-fold>//GEN-END:initComponents

	 private void okActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okActionPerformed
		 
	 }//GEN-LAST:event_okActionPerformed

	 private void cancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelActionPerformed
		 this.dispose();
	 }//GEN-LAST:event_cancelActionPerformed

	 private void browseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseActionPerformed
		 JFileChooser jfc = new JFileChooser();
		 int r = jfc.showOpenDialog(this);
		 if (r == JFileChooser.APPROVE_OPTION) {
			 netmorphExec.setText(jfc.getSelectedFile().getAbsolutePath());
		 }
	 }//GEN-LAST:event_browseActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new NeuroviewPreferences().setVisible(true);
            }
        });
    }

   // Variables declaration - do not modify//GEN-BEGIN:variables
   private javax.swing.JButton browse;
   private javax.swing.JButton cancel;
   private javax.swing.JLabel jLabel1;
   private javax.swing.JTextField netmorphExec;
   private javax.swing.JButton ok;
   // End of variables declaration//GEN-END:variables

}
